package com.mate.cloud.redisson.datatype;

import io.netty.util.HashedWheelTimer;
import io.netty.util.Timeout;
import io.netty.util.Timer;
import io.netty.util.TimerTask;

import java.util.concurrent.TimeUnit;

public class TimerTest {
    public static void main(String[] args) throws InterruptedException {
        Timer timer=new HashedWheelTimer();  //创建了一个时间轮
        timer.newTimeout(new TimerTask() {
            @Override
            public void run(Timeout timeout) throws Exception {
                //任务
                System.out.println("10s后我来执行这个任务");
            }
        },10,TimeUnit.SECONDS);


        timer.newTimeout(timeout -> System.out.println("20s后执行"),20,TimeUnit.SECONDS);

    }
}
